import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class Test05 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Builder(builder: (BuildContext context){
        RenderBox renderObject = context.findRenderObject();
        Shader linearGradient = LinearGradient(colors: [Colors.red,Colors.black]).createShader(
            Rect.fromLTWH(0, 0, renderObject?.size?.width, renderObject?.size?.height)
        );
        return Text("测试文字变色,测试文字变色，测试文字变色",
            style: TextStyle(
              fontSize:20,
              fontStyle: FontStyle.italic,
              foreground: Paint()..shader=linearGradient,
            ));
      }),
    );
  }
}
